package com.example.yiwei.crm.view.Class.listviewClass;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.yiwei.crm.R;
import com.example.yiwei.crm.entity.LogEntity;

import java.util.List;


/**
 * Created by DHN on 2017/4/28.
 */

public class OperationLogAdapter extends BaseAdapter{
   private List<LogEntity> logEntityList;
   private LogEntity logEntity ;
   private LayoutInflater inflater ;
   private Context context;
    public OperationLogAdapter(Context context, List<LogEntity> list){
        this.context = context;
        this.logEntityList = list;
        inflater =LayoutInflater.from(context);

    }
    @Override
    public int getCount() {
        return logEntityList.size();
    }

    @Override
    public Object getItem(int position) {
        return logEntityList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        logEntity = logEntityList.get(position);
        if (convertView==null){
            convertView = inflater.inflate(R.layout.layout_item_operation_log,null);
            holder = new ViewHolder();
            holder.work = (TextView) convertView.findViewById(R.id.work2);
            holder.content = (TextView) convertView.findViewById(R.id.content2);
            holder.name = (TextView) convertView.findViewById(R.id.name1);
            holder.time = (TextView) convertView.findViewById(R.id.time1);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.work.setText(logEntity.getWork());
        holder.content.setText(logEntity.getSubstance());
        holder.name.setText(logEntity.getPeople());
        holder.time.setText(logEntity.getTime());
        return convertView;
    }
    class ViewHolder{
        TextView work;
        TextView content;
        TextView name;
        TextView time;
    }
}
